package com.sky.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.ItemPageQueryDTO;
import com.sky.entity.Item;
import com.sky.mapper.ItemMapper;
import com.sky.mapper.StandardMapper;
import com.sky.result.PageResult;
import com.sky.service.ItemService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
@RequiredArgsConstructor
/*public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements ItemService {

}*/
public class ItemServiceImpl implements ItemService {
    @Autowired
    private ItemMapper itemMapper;
    @Override
    public PageResult select(ItemPageQueryDTO itemPageQueryDTO) {
        //开始分页查询  动态地将数字拼接到里面  limit
        PageHelper pageHelper = new PageHelper();
        Page<Object> objects = pageHelper.startPage(itemPageQueryDTO.getPage(), itemPageQueryDTO.getPageSize());
//姓名还需要动态的拼接到sql中
     Page<Item>page=itemMapper.select(itemPageQueryDTO);
        long total = page.getTotal();
        List<Item> result =page.getResult();
        return new PageResult(total,result);
    }
}
